package com.tencent.stat.common;

import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.ActivityManager.RunningTaskInfo;
import android.bluetooth.BluetoothAdapter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.Size;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Proxy;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Environment;
import android.os.Process;
import android.os.StatFs;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import com.tencent.stat.StatConfig;
import com.tencent.stat.StatReportStrategy;
import com.tencent.stat.StatSpecifyReportedInfo;
import com.tencent.stat.aw;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.RandomAccessFile;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.zip.GZIPInputStream;
import org.apache.http.HttpHost;
import org.json.JSONObject;

public class StatCommonHelper
{
  private static String a = null;
  private static String b = null;
  private static String c = null;
  private static String d = null;
  private static Random e = null;
  private static DisplayMetrics f = null;
  private static String g = null;
  private static String h = "";
  private static String i = "";
  private static String j = "";
  private static String k = "";
  private static int l = -1;
  private static StatLogger m = null;
  private static String n = null;
  private static String o = null;
  private static volatile int p = -1;
  private static String q = null;
  private static String r = null;
  private static long s = -1L;
  private static String t = "";
  private static n u = null;
  private static String v = "__MTA_FIRST_ACTIVATE__";
  private static int w = -1;
  private static long x = -1L;
  private static int y = 0;
  private static String z = "";

  static String a(Context paramContext)
  {
    try
    {
      ActivityManager.RunningAppProcessInfo localRunningAppProcessInfo;
      if (o != null)
        return o;
      int i1 = Process.myPid();
      paramContext = ((ActivityManager)paramContext.getSystemService("activity")).getRunningAppProcesses().iterator();
      do
        if (paramContext.hasNext())
          localRunningAppProcessInfo = (ActivityManager.RunningAppProcessInfo)paramContext.next();
      while (localRunningAppProcessInfo.pid != i1);
      o = localRunningAppProcessInfo.processName;
      return o;
    }
    catch (Throwable paramContext)
    {
    }
  }

  private static long b(Context paramContext)
  {
    paramContext = (ActivityManager)paramContext.getSystemService("activity");
    ActivityManager.MemoryInfo localMemoryInfo = new ActivityManager.MemoryInfo();
    paramContext.getMemoryInfo(localMemoryInfo);
    return localMemoryInfo.availMem;
  }

  private static Random b()
  {
    monitorenter;
    try
    {
      if (e == null)
        e = new Random();
      Random localRandom = e;
      return localRandom;
    }
    finally
    {
      monitorexit;
    }
  }

  // ERROR //
  private static long c()
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore 6
    //   3: getstatic 81	com/tencent/stat/common/StatCommonHelper:s	J
    //   6: lconst_0
    //   7: lcmp
    //   8: ifle +7 -> 15
    //   11: getstatic 81	com/tencent/stat/common/StatCommonHelper:s	J
    //   14: lreturn
    //   15: lconst_1
    //   16: lstore_3
    //   17: new 169	java/io/FileReader
    //   20: dup
    //   21: ldc 171
    //   23: invokespecial 174	java/io/FileReader:<init>	(Ljava/lang/String;)V
    //   26: astore 7
    //   28: new 176	java/io/BufferedReader
    //   31: dup
    //   32: aload 7
    //   34: sipush 8192
    //   37: invokespecial 179	java/io/BufferedReader:<init>	(Ljava/io/Reader;I)V
    //   40: astore 5
    //   42: aload 5
    //   44: invokevirtual 183	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   47: astore 6
    //   49: lload_3
    //   50: lstore_1
    //   51: aload 6
    //   53: ifnull +26 -> 79
    //   56: aload 6
    //   58: ldc 185
    //   60: invokevirtual 191	java/lang/String:split	(Ljava/lang/String;)[Ljava/lang/String;
    //   63: iconst_1
    //   64: aaload
    //   65: invokestatic 197	java/lang/Integer:valueOf	(Ljava/lang/String;)Ljava/lang/Integer;
    //   68: invokevirtual 200	java/lang/Integer:intValue	()I
    //   71: istore_0
    //   72: iload_0
    //   73: sipush 1024
    //   76: imul
    //   77: i2l
    //   78: lstore_1
    //   79: aload 7
    //   81: invokevirtual 203	java/io/FileReader:close	()V
    //   84: aload 5
    //   86: invokevirtual 204	java/io/BufferedReader:close	()V
    //   89: lload_1
    //   90: putstatic 81	com/tencent/stat/common/StatCommonHelper:s	J
    //   93: lload_1
    //   94: lreturn
    //   95: astore 5
    //   97: aload 5
    //   99: invokevirtual 207	java/lang/Exception:printStackTrace	()V
    //   102: goto -13 -> 89
    //   105: astore 7
    //   107: aconst_null
    //   108: astore 5
    //   110: aload 7
    //   112: invokevirtual 207	java/lang/Exception:printStackTrace	()V
    //   115: aload 6
    //   117: ifnull +8 -> 125
    //   120: aload 6
    //   122: invokevirtual 203	java/io/FileReader:close	()V
    //   125: lload_3
    //   126: lstore_1
    //   127: aload 5
    //   129: ifnull -40 -> 89
    //   132: aload 5
    //   134: invokevirtual 204	java/io/BufferedReader:close	()V
    //   137: lload_3
    //   138: lstore_1
    //   139: goto -50 -> 89
    //   142: astore 5
    //   144: aload 5
    //   146: invokevirtual 207	java/lang/Exception:printStackTrace	()V
    //   149: lload_3
    //   150: lstore_1
    //   151: goto -62 -> 89
    //   154: astore 6
    //   156: aconst_null
    //   157: astore 5
    //   159: aconst_null
    //   160: astore 7
    //   162: aload 7
    //   164: ifnull +8 -> 172
    //   167: aload 7
    //   169: invokevirtual 203	java/io/FileReader:close	()V
    //   172: aload 5
    //   174: ifnull +8 -> 182
    //   177: aload 5
    //   179: invokevirtual 204	java/io/BufferedReader:close	()V
    //   182: aload 6
    //   184: athrow
    //   185: astore 5
    //   187: aload 5
    //   189: invokevirtual 207	java/lang/Exception:printStackTrace	()V
    //   192: goto -10 -> 182
    //   195: astore 6
    //   197: aconst_null
    //   198: astore 5
    //   200: goto -38 -> 162
    //   203: astore 6
    //   205: goto -43 -> 162
    //   208: astore 8
    //   210: aload 6
    //   212: astore 7
    //   214: aload 8
    //   216: astore 6
    //   218: goto -56 -> 162
    //   221: astore 8
    //   223: aconst_null
    //   224: astore 5
    //   226: aload 7
    //   228: astore 6
    //   230: aload 8
    //   232: astore 7
    //   234: goto -124 -> 110
    //   237: astore 8
    //   239: aload 7
    //   241: astore 6
    //   243: aload 8
    //   245: astore 7
    //   247: goto -137 -> 110
    //
    // Exception table:
    //   from	to	target	type
    //   79	89	95	java/lang/Exception
    //   17	28	105	java/lang/Exception
    //   120	125	142	java/lang/Exception
    //   132	137	142	java/lang/Exception
    //   17	28	154	finally
    //   167	172	185	java/lang/Exception
    //   177	182	185	java/lang/Exception
    //   28	42	195	finally
    //   42	49	203	finally
    //   56	72	203	finally
    //   110	115	208	finally
    //   28	42	221	java/lang/Exception
    //   42	49	237	java/lang/Exception
    //   56	72	237	java/lang/Exception
  }

  public static int checkBluetooth()
  {
    BluetoothAdapter localBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (localBluetoothAdapter == null)
      return -1;
    if (localBluetoothAdapter.isEnabled())
      return 1;
    return 0;
  }

  public static void checkFirstTimeActivate(Context paramContext)
  {
    int i1 = StatPreferences.getInt(paramContext, v, 1);
    w = i1;
    if (i1 != 1)
      return;
    StatPreferences.putInt(paramContext, v, 0);
  }

  public static boolean checkPhoneState(Context paramContext)
  {
    return (paramContext.getPackageManager().checkPermission("android.permission.READ_PHONE_STATE", paramContext.getPackageName()) != 0);
  }

  public static Long convertStringToLong(String paramString1, String paramString2, int paramInt1, int paramInt2, Long paramLong)
  {
    if ((paramString1 == null) || (paramString2 == null));
    do
    {
      return paramLong;
      if (!(paramString2.equalsIgnoreCase(".")))
      {
        str = paramString2;
        if (!(paramString2.equalsIgnoreCase("|")))
          break label52;
      }
      String str = "\\" + paramString2;
      label52: paramString2 = paramString1.split(str);
    }
    while (paramString2.length != paramInt2);
    try
    {
      paramString1 = Long.valueOf(0L);
      paramInt2 = 0;
      while (paramInt2 < paramString2.length)
      {
        long l1 = paramInt1;
        long l2 = paramString1.longValue();
        long l3 = Long.valueOf(paramString2[paramInt2]).longValue();
        paramInt2 += 1;
        paramString1 = Long.valueOf(l1 * (l2 + l3));
      }
      return paramString1;
    }
    catch (java.lang.NumberFormatException paramString1)
    {
    }
    return paramLong;
  }

  public static byte[] deocdeGZipContent(byte[] paramArrayOfByte)
  {
    ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(paramArrayOfByte);
    GZIPInputStream localGZIPInputStream = new GZIPInputStream(localByteArrayInputStream);
    byte[] arrayOfByte = new byte[4096];
    paramArrayOfByte = new ByteArrayOutputStream(paramArrayOfByte.length * 2);
    while (true)
    {
      int i1 = localGZIPInputStream.read(arrayOfByte);
      if (i1 == -1)
        break;
      paramArrayOfByte.write(arrayOfByte, 0, i1);
    }
    arrayOfByte = paramArrayOfByte.toByteArray();
    localByteArrayInputStream.close();
    localGZIPInputStream.close();
    paramArrayOfByte.close();
    return arrayOfByte;
  }

  public static String getActivityName(Context paramContext)
  {
    if (paramContext == null)
      return null;
    return paramContext.getClass().getName();
  }

  public static String getAllSensors(Context paramContext)
  {
    int i1;
    if (isStringValid(t))
      return t;
    try
    {
      paramContext = (SensorManager)paramContext.getSystemService("sensor");
      if (paramContext != null)
      {
        paramContext = paramContext.getSensorList(-1);
        if (paramContext != null)
        {
          StringBuilder localStringBuilder = new StringBuilder(paramContext.size() * 10);
          i1 = 0;
          if (i1 < paramContext.size())
          {
            localStringBuilder.append(((Sensor)paramContext.get(i1)).getType());
            if (i1 == paramContext.size() - 1)
              break label130;
            localStringBuilder.append(",");
            break label130:
          }
          t = localStringBuilder.toString();
        }
      }
      label130: return t;
    }
    catch (Throwable paramContext)
    {
      while (true)
        m.e(paramContext);
      i1 += 1;
    }
  }

  public static int getAndroidOsBuildVersion()
  {
    return Build.VERSION.SDK_INT;
  }

  public static String getAppKey(Context paramContext)
  {
    if (b != null)
      return b;
    while (true)
    {
      try
      {
        paramContext = paramContext.getPackageManager().getApplicationInfo(paramContext.getPackageName(), 128);
        if (paramContext == null)
          break label60;
        paramContext = paramContext.metaData.getString("TA_APPKEY");
        if (paramContext == null)
          break label62;
        b = paramContext;
        label60: return paramContext;
      }
      catch (Throwable paramContext)
      {
        m.i("Could not read APPKEY meta-data from AndroidManifest.xml");
        return null;
      }
      label62: m.i("Could not read APPKEY meta-data from AndroidManifest.xml");
    }
  }

  public static String getAppVersion(Context paramContext)
  {
    if (isStringValid(k))
      return k;
    try
    {
      paramContext = paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 0).versionName;
      k = paramContext;
      if ((paramContext != null) && (k.length() != 0))
        break label58;
      return "unknown";
    }
    catch (Throwable paramContext)
    {
      m.e(paramContext);
    }
    label58: return k;
  }

  public static String getCameras(Context paramContext)
  {
    if (isStringValid(z))
      return z;
    Object localObject4 = null;
    Object localObject5 = null;
    Object localObject3 = null;
    Object localObject2 = localObject4;
    Object localObject1 = localObject5;
    try
    {
      if (Util.checkPermission(paramContext, "android.permission.CAMERA"))
      {
        localObject2 = localObject4;
        localObject1 = localObject5;
        paramContext = Camera.open();
        localObject3 = paramContext;
        if (paramContext != null)
        {
          localObject2 = paramContext;
          localObject1 = paramContext;
          localObject3 = (Camera.Size)paramContext.getParameters().getSupportedPictureSizes().get(0);
          localObject2 = paramContext;
          localObject1 = paramContext;
          z = ((Camera.Size)localObject3).width + "*" + ((Camera.Size)localObject3).height;
          localObject3 = paramContext;
        }
      }
      return z;
    }
    catch (Throwable paramContext)
    {
      localObject1 = localObject2;
      m.w("getCameras failed, " + paramContext.toString());
    }
    finally
    {
      if (localObject1 != null)
        ((Camera)localObject1).release();
    }
  }

  public static n getCamerasHelper(Context paramContext)
  {
    monitorenter;
    try
    {
      if (u == null)
        u = new n();
      paramContext = u;
      return paramContext;
    }
    finally
    {
      monitorexit;
    }
  }

  public static JSONObject getCpuInfo(Context paramContext)
  {
    paramContext = new JSONObject();
    try
    {
      paramContext.put("n", l.a());
      String str = l.d();
      if ((str != null) && (str.length() > 0))
        paramContext.put("na", str);
      int i1 = l.b();
      if (i1 > 0)
        paramContext.put("fx", i1 / 1000000);
      i1 = l.c();
      if (i1 > 0)
        paramContext.put("fn", i1 / 1000000);
      return paramContext;
    }
    catch (Throwable localThrowable)
    {
      Log.w("MtaSDK", "get cpu error", localThrowable);
    }
    return paramContext;
  }

  public static String getCpuString()
  {
    if (isStringValid(q))
      return q;
    if (Build.CPU_ABI.equalsIgnoreCase("x86"))
      q = "Intel";
    while (true)
    {
      return q;
      try
      {
        Object localObject = new byte[1024];
        RandomAccessFile localRandomAccessFile = new RandomAccessFile("/proc/cpuinfo", "r");
        localRandomAccessFile.read(localObject);
        localRandomAccessFile.close();
        localObject = new String(localObject);
        int i1 = ((String)localObject).indexOf(0);
        if (i1 == -1)
          break label108;
        q = ((String)localObject).substring(0, i1);
      }
      catch (Throwable localThrowable)
      {
        m.e(localThrowable);
      }
      label108: q = localThrowable;
    }
  }

  public static String getCpuType()
  {
    String str2 = getCpuString();
    if (str2.contains("ARMv5"));
    for (String str1 = "armv5"; ; str1 = "x86")
    {
      while (true)
      {
        if (!(str2.contains("neon")))
          break label104;
        return str1 + "_neon";
        if (str2.contains("ARMv6"))
          str1 = "armv6";
        if (!(str2.contains("ARMv7")))
          break;
        str1 = "armv7";
      }
      if (!(str2.contains("Intel")))
        break;
    }
    return "unknown";
    if (str2.contains("vfpv3"))
      label104: return str1 + "_vfpv3";
    if (str2.contains(" vfp"))
      return str1 + "_vfp";
    return str1 + "_none";
  }

  public static String getCurAppMd5Signature(Context paramContext)
  {
    if (isStringValid(i))
      return i;
    try
    {
      paramContext = paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 64);
      if (paramContext == null)
      {
        m.e("packageInfo is null ");
        return "";
      }
      paramContext = paramContext.signatures;
      if ((paramContext == null) || (paramContext.length == 0))
      {
        m.e("signatures is null");
        return "";
      }
      i = md5sum(paramContext[0].toCharsString());
      return i;
    }
    catch (Throwable paramContext)
    {
      m.e(paramContext);
    }
  }

  public static String getCurAppSHA1Signature(Context paramContext)
  {
    int i1 = 0;
    if (isStringValid(j))
      return j;
    try
    {
      paramContext = paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 64);
      if (paramContext == null)
      {
        m.e("packageInfo is null ");
        return "";
      }
      paramContext = paramContext.signatures;
      if ((paramContext == null) || (paramContext.length == 0))
      {
        m.e("signatures is null");
        return "";
      }
      paramContext = paramContext[0].toByteArray();
      paramContext = MessageDigest.getInstance("SHA1").digest(paramContext);
      StringBuffer localStringBuffer = new StringBuffer();
      int i2 = paramContext.length;
      if (i1 < i2)
      {
        String str = Integer.toHexString(paramContext[i1] & 0xFF).toUpperCase(Locale.US);
        if (str.length() == 1)
          localStringBuffer.append("0");
        localStringBuffer.append(str);
        if (i1 == i2 - 1)
          break label200;
        localStringBuffer.append(":");
        break label200:
      }
      j = localStringBuffer.toString();
      label200: return j;
    }
    catch (PackageManager.NameNotFoundException paramContext)
    {
      paramContext.printStackTrace();
    }
    catch (NoSuchAlgorithmException paramContext)
    {
      paramContext.printStackTrace();
    }
    catch (Throwable paramContext)
    {
      while (true)
      {
        while (true)
          paramContext.printStackTrace();
        i1 += 1;
      }
    }
  }

  public static String getCurAppVersion(Context paramContext)
  {
    if (isStringValid(h))
      return h;
    try
    {
      paramContext = paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 0).versionName;
      h = paramContext;
      if (paramContext != null)
        break label48;
      return "";
    }
    catch (Throwable paramContext)
    {
      m.e(paramContext);
    }
    label48: return h;
  }

  public static String getDatabaseName(Context paramContext)
  {
    return getTagForConcurrentProcess(paramContext, StatConstants.DATABASE_NAME);
  }

  public static String getDateFormat(long paramLong)
  {
    return new SimpleDateFormat("yyyyMMdd").format(new Date(paramLong));
  }

  public static String getDateString(int paramInt)
  {
    Calendar localCalendar = Calendar.getInstance();
    localCalendar.roll(6, paramInt);
    return new SimpleDateFormat("yyyyMMdd").format(localCalendar.getTime());
  }

  public static String getDeviceIMSI(Context paramContext)
  {
    while (true)
    {
      try
      {
        if (!(Util.checkPermission(paramContext, "android.permission.READ_PHONE_STATE")))
          break label46;
        if (!(checkPhoneState(paramContext)))
          break label49;
        paramContext = ((TelephonyManager)paramContext.getSystemService("phone")).getSubscriberId();
        if (paramContext != null)
          return paramContext;
        label46: return null;
      }
      catch (Throwable paramContext)
      {
        m.e(paramContext);
        return "";
      }
      label49: paramContext = null;
    }
  }

  public static String getDeviceModel(Context paramContext)
  {
    if (d == null)
      d = Build.MODEL;
    return d;
  }

  public static int getDiffTime(Context paramContext, boolean paramBoolean)
  {
    if (paramBoolean)
      y = readDiffTimeFromServer(paramContext);
    return y;
  }

  public static DisplayMetrics getDisplayMetrics(Context paramContext)
  {
    if (f == null)
    {
      f = new DisplayMetrics();
      ((WindowManager)paramContext.getApplicationContext().getSystemService("window")).getDefaultDisplay().getMetrics(f);
    }
    return f;
  }

  public static String getExternalStorageInfo(Context paramContext)
  {
    if (isStringValid(n))
      return n;
    try
    {
      if (!(Util.checkPermission(paramContext, "android.permission.WRITE_EXTERNAL_STORAGE")))
        break label142;
      paramContext = Environment.getExternalStorageState();
      if ((paramContext == null) || (!(paramContext.equals("mounted"))))
        break label140;
      paramContext = Environment.getExternalStorageDirectory().getPath();
      if (paramContext == null)
        break label140;
      paramContext = new StatFs(paramContext);
      long l1 = paramContext.getBlockCount() * paramContext.getBlockSize() / 1000000L;
      long l2 = paramContext.getAvailableBlocks();
      l2 = paramContext.getBlockSize() * l2 / 1000000L;
      paramContext = String.valueOf(l2) + "/" + String.valueOf(l1);
      n = paramContext;
      label140: return paramContext;
    }
    catch (Throwable paramContext)
    {
      m.e(paramContext);
      return null;
    }
    label142: m.warn("can not get the permission of android.permission.WRITE_EXTERNAL_STORAGE");
    return null;
  }

  // ERROR //
  public static android.location.Location getGPSLocation(Context paramContext)
  {
    // Byte code:
    //   0: aload_0
    //   1: ldc_w 749
    //   4: invokestatic 411	com/tencent/stat/common/Util:checkPermission	(Landroid/content/Context;Ljava/lang/String;)Z
    //   7: ifeq +82 -> 89
    //   10: getstatic 67	com/tencent/stat/common/StatCommonHelper:m	Lcom/tencent/stat/common/StatLogger;
    //   13: ldc_w 750
    //   16: invokevirtual 556	com/tencent/stat/common/StatLogger:e	(Ljava/lang/Object;)V
    //   19: aload_0
    //   20: ldc_w 752
    //   23: invokevirtual 119	android/content/Context:getSystemService	(Ljava/lang/String;)Ljava/lang/Object;
    //   26: checkcast 754	android/location/LocationManager
    //   29: astore_0
    //   30: aload_0
    //   31: ldc_w 756
    //   34: invokevirtual 759	android/location/LocationManager:isProviderEnabled	(Ljava/lang/String;)Z
    //   37: ifeq +52 -> 89
    //   40: aload_0
    //   41: ldc_w 756
    //   44: invokevirtual 763	android/location/LocationManager:getLastKnownLocation	(Ljava/lang/String;)Landroid/location/Location;
    //   47: astore_0
    //   48: getstatic 67	com/tencent/stat/common/StatCommonHelper:m	Lcom/tencent/stat/common/StatLogger;
    //   51: new 260	java/lang/StringBuilder
    //   54: dup
    //   55: ldc_w 765
    //   58: invokespecial 263	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   61: aload_0
    //   62: invokevirtual 768	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   65: invokevirtual 270	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   68: invokevirtual 556	com/tencent/stat/common/StatLogger:e	(Ljava/lang/Object;)V
    //   71: aload_0
    //   72: areturn
    //   73: astore_1
    //   74: aconst_null
    //   75: astore_0
    //   76: getstatic 67	com/tencent/stat/common/StatCommonHelper:m	Lcom/tencent/stat/common/StatLogger;
    //   79: aload_1
    //   80: invokevirtual 358	com/tencent/stat/common/StatLogger:e	(Ljava/lang/Throwable;)V
    //   83: aload_0
    //   84: areturn
    //   85: astore_1
    //   86: goto -10 -> 76
    //   89: aconst_null
    //   90: areturn
    //
    // Exception table:
    //   from	to	target	type
    //   0	48	73	java/lang/Throwable
    //   48	71	85	java/lang/Throwable
  }

  public static HttpHost getHttpProxy(Context paramContext)
  {
    if (paramContext == null)
      return null;
    do
    {
      try
      {
        if (paramContext.getPackageManager().checkPermission("android.permission.ACCESS_NETWORK_STATE", paramContext.getPackageName()) != 0)
          return null;
        paramContext = ((ConnectivityManager)paramContext.getSystemService("connectivity")).getActiveNetworkInfo();
        if (paramContext == null)
          return null;
        if ((paramContext.getTypeName() != null) && (paramContext.getTypeName().equalsIgnoreCase("WIFI")))
          return null;
        paramContext = paramContext.getExtraInfo();
        if (paramContext == null)
          return null;
        if ((!(paramContext.equals("cmwap"))) && (!(paramContext.equals("3gwap"))) && (!(paramContext.equals("uniwap"))))
          break label133;
        paramContext = new HttpHost("10.0.0.172", 80);
        return paramContext;
      }
      catch (Throwable paramContext)
      {
        m.e(paramContext);
        return null;
      }
      if (paramContext.equals("ctwap"))
        label133: return new HttpHost("10.0.0.200", 80);
      paramContext = Proxy.getDefaultHost();
    }
    while ((paramContext == null) || (paramContext.trim().length() <= 0));
    paramContext = new HttpHost(paramContext, Proxy.getDefaultPort());
    return paramContext;
  }

  public static String getInstallChannel(Context paramContext)
  {
    try
    {
      paramContext = paramContext.getPackageManager().getApplicationInfo(paramContext.getPackageName(), 128);
      if (paramContext != null)
      {
        paramContext = paramContext.metaData.get("InstallChannel");
        if (paramContext != null)
          return paramContext.toString();
        m.w("Could not read InstallChannel meta-data from AndroidManifest.xml");
      }
      return null;
    }
    catch (Throwable paramContext)
    {
      m.e("Could not read InstallChannel meta-data from AndroidManifest.xml");
    }
  }

  public static String getLauncherPackageName(Context paramContext)
  {
    if (paramContext == null);
    do
    {
      return null;
      Intent localIntent = new Intent("android.intent.action.MAIN");
      localIntent.addCategory("android.intent.category.HOME");
      paramContext = paramContext.getPackageManager().resolveActivity(localIntent, 0);
    }
    while ((paramContext.activityInfo == null) || (paramContext.activityInfo.packageName.equals("android")));
    return paramContext.activityInfo.packageName;
  }

  public static String getLinkedWay(Context paramContext)
  {
    try
    {
      if ((Util.checkPermission(paramContext, "android.permission.INTERNET")) && (Util.checkPermission(paramContext, "android.permission.ACCESS_NETWORK_STATE")))
      {
        paramContext = ((ConnectivityManager)paramContext.getSystemService("connectivity")).getActiveNetworkInfo();
        if ((paramContext == null) || (!(paramContext.isConnected())))
          break label146;
        String str1 = paramContext.getTypeName();
        String str2 = paramContext.getExtraInfo();
        if (str1 == null)
          break label146;
        if (str1.equalsIgnoreCase("WIFI"))
          return "WIFI";
        if (str1.equalsIgnoreCase("MOBILE"))
        {
          if ((str2 == null) || (str2.trim().length() <= 0))
            break label142;
          return str2;
        }
        paramContext = str1;
        if (str2 == null)
          break label149;
        paramContext = str1;
        if (str2.trim().length() <= 0)
          break label149;
        return str2;
      }
      m.e("can not get the permission of android.permission.ACCESS_WIFI_STATE");
      return "";
    }
    catch (Throwable paramContext)
    {
      m.e(paramContext);
      return "";
    }
    label142: return "MOBILE";
    label146: paramContext = "";
    label149: return paramContext;
  }

  public static StatLogger getLogger()
  {
    monitorenter;
    try
    {
      if (m == null)
      {
        localStatLogger = new StatLogger("MtaSDK");
        m = localStatLogger;
        localStatLogger.setDebugEnable(false);
      }
      StatLogger localStatLogger = m;
      return localStatLogger;
    }
    finally
    {
      monitorexit;
    }
  }

  public static String getMacId(Context paramContext)
  {
    monitorenter;
    try
    {
      if ((c == null) || (c.trim().length() == 0))
        c = Util.getWifiMacAddress(paramContext);
      paramContext = c;
      return paramContext;
    }
    finally
    {
      monitorexit;
    }
  }

  // ERROR //
  public static android.location.Location getNetworkLocation(Context paramContext)
  {
    // Byte code:
    //   0: aload_0
    //   1: ldc_w 878
    //   4: invokestatic 411	com/tencent/stat/common/Util:checkPermission	(Landroid/content/Context;Ljava/lang/String;)Z
    //   7: ifne +13 -> 20
    //   10: aload_0
    //   11: ldc_w 749
    //   14: invokestatic 411	com/tencent/stat/common/Util:checkPermission	(Landroid/content/Context;Ljava/lang/String;)Z
    //   17: ifeq +87 -> 104
    //   20: getstatic 67	com/tencent/stat/common/StatCommonHelper:m	Lcom/tencent/stat/common/StatLogger;
    //   23: ldc_w 879
    //   26: invokevirtual 556	com/tencent/stat/common/StatLogger:e	(Ljava/lang/Object;)V
    //   29: aload_0
    //   30: ldc_w 752
    //   33: invokevirtual 119	android/content/Context:getSystemService	(Ljava/lang/String;)Ljava/lang/Object;
    //   36: checkcast 754	android/location/LocationManager
    //   39: astore_0
    //   40: aload_0
    //   41: ldc_w 881
    //   44: invokevirtual 759	android/location/LocationManager:isProviderEnabled	(Ljava/lang/String;)Z
    //   47: ifeq +52 -> 99
    //   50: aload_0
    //   51: ldc_w 881
    //   54: invokevirtual 763	android/location/LocationManager:getLastKnownLocation	(Ljava/lang/String;)Landroid/location/Location;
    //   57: astore_0
    //   58: getstatic 67	com/tencent/stat/common/StatCommonHelper:m	Lcom/tencent/stat/common/StatLogger;
    //   61: new 260	java/lang/StringBuilder
    //   64: dup
    //   65: ldc_w 883
    //   68: invokespecial 263	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   71: aload_0
    //   72: invokevirtual 768	java/lang/StringBuilder:append	(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    //   75: invokevirtual 270	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   78: invokevirtual 556	com/tencent/stat/common/StatLogger:e	(Ljava/lang/Object;)V
    //   81: aload_0
    //   82: areturn
    //   83: astore_1
    //   84: aconst_null
    //   85: astore_0
    //   86: getstatic 67	com/tencent/stat/common/StatCommonHelper:m	Lcom/tencent/stat/common/StatLogger;
    //   89: aload_1
    //   90: invokevirtual 358	com/tencent/stat/common/StatLogger:e	(Ljava/lang/Throwable;)V
    //   93: aload_0
    //   94: areturn
    //   95: astore_1
    //   96: goto -10 -> 86
    //   99: aconst_null
    //   100: astore_0
    //   101: goto -43 -> 58
    //   104: aconst_null
    //   105: areturn
    //
    // Exception table:
    //   from	to	target	type
    //   0	20	83	java/lang/Throwable
    //   20	58	83	java/lang/Throwable
    //   58	81	95	java/lang/Throwable
  }

  public static Integer getNextEventIndexNo(Context paramContext)
  {
    int i1 = 0;
    monitorenter;
    while (true)
    {
      int i2;
      try
      {
        if (p <= 0)
          break label79;
        if (i2 % 1000 != 0);
      }
      finally
      {
        try
        {
          i2 = p;
          if (p < 2147383647)
            break label107;
          StatPreferences.putInt(paramContext, "MTA_EVENT_INDEX", i1);
          i1 = p + 1;
          p = i1;
          monitorexit;
          return Integer.valueOf(i1);
        }
        catch (Throwable paramContext)
        {
          while (true)
            m.w(paramContext);
          paramContext = finally;
          monitorexit;
          throw paramContext;
        }
      }
      label79: p = StatPreferences.getInt(paramContext, "MTA_EVENT_INDEX", 0);
      StatPreferences.putInt(paramContext, "MTA_EVENT_INDEX", p + 1000);
      continue;
      label107: i1 = i2 + 1000;
    }
  }

  public static int getNextSessionID()
  {
    return b().nextInt(2147483647);
  }

  public static String getPackageName(Context paramContext)
  {
    if (Util.checkPermission(paramContext, "android.permission.GET_TASKS"))
      return ((ActivityManager.RunningTaskInfo)((ActivityManager)paramContext.getSystemService("activity")).getRunningTasks(1).get(0)).topActivity.getPackageName();
    m.e("Could not get permission of android.permission.GET_TASKS");
    return null;
  }

  public static String getProperty(Context paramContext, String paramString)
  {
    try
    {
      paramContext = paramContext.getPackageManager().getApplicationInfo(paramContext.getPackageName(), 128);
      if (paramContext == null)
        break label42;
      paramContext = paramContext.metaData.getString(paramString);
      if (paramContext == null)
        break label42;
      return paramContext;
    }
    catch (Throwable paramContext)
    {
      m.e(paramContext);
    }
    label42: return "";
  }

  public static String getRomMemory()
  {
    if (isStringValid(r))
      return r;
    long l1 = getTotalInternalMemorySize() / 1000000L;
    Object localObject = new StatFs(Environment.getDataDirectory().getPath());
    long l2 = ((StatFs)localObject).getBlockSize();
    l2 = ((StatFs)localObject).getAvailableBlocks() * l2 / 1000000L;
    localObject = String.valueOf(l2) + "/" + String.valueOf(l1);
    r = (String)localObject;
    return ((String)localObject);
  }

  public static long getSDKLongVersion(String paramString)
  {
    return convertStringToLong(paramString, ".", 100, 3, Long.valueOf(0L)).longValue();
  }

  public static String getSimOperator(Context paramContext)
  {
    if (g != null)
      return g;
    while (true)
      try
      {
        if (Util.checkPermission(paramContext, "android.permission.READ_PHONE_STATE"))
        {
          if (checkPhoneState(paramContext))
          {
            paramContext = (TelephonyManager)paramContext.getSystemService("phone");
            if (paramContext != null)
              g = paramContext.getSimOperator();
          }
          return g;
        }
        m.e("Could not get permission of android.permission.READ_PHONE_STATE");
      }
      catch (Throwable paramContext)
      {
        m.e(paramContext);
      }
  }

  public static StatReportStrategy getStatSendStrategy(Context paramContext)
  {
    return StatConfig.getStatSendStrategy();
  }

  public static String getSystemMemory(Context paramContext)
  {
    try
    {
      long l1 = b(paramContext) / 1000000L;
      long l2 = c() / 1000000L;
      paramContext = String.valueOf(l1) + "/" + String.valueOf(l2);
      return paramContext;
    }
    catch (Throwable paramContext)
    {
      paramContext.printStackTrace();
    }
    return null;
  }

  public static String getTagForConcurrentProcess(Context paramContext, String paramString)
  {
    String str = paramString;
    if (StatConfig.isEnableConcurrentProcess() == true)
    {
      if (o == null)
        o = a(paramContext);
      str = paramString;
      if (o != null)
        str = paramString + "_" + o;
    }
    return str;
  }

  public static Integer getTelephonyNetworkType(Context paramContext)
  {
    try
    {
      paramContext = (TelephonyManager)paramContext.getSystemService("phone");
      if (paramContext == null)
        break label26;
      int i1 = paramContext.getNetworkType();
      return Integer.valueOf(i1);
    }
    catch (Throwable paramContext)
    {
    }
    label26: return null;
  }

  public static long getTomorrowStartMilliseconds()
  {
    try
    {
      Calendar localCalendar = Calendar.getInstance();
      localCalendar.set(11, 0);
      localCalendar.set(12, 0);
      localCalendar.set(13, 0);
      localCalendar.set(14, 0);
      long l1 = localCalendar.getTimeInMillis();
      return (l1 + 86400000L);
    }
    catch (Throwable localThrowable)
    {
      m.e(localThrowable);
    }
    return (System.currentTimeMillis() + 86400000L);
  }

  public static long getTotalInternalMemorySize()
  {
    StatFs localStatFs = new StatFs(Environment.getDataDirectory().getPath());
    long l1 = localStatFs.getBlockSize();
    return (localStatFs.getBlockCount() * l1);
  }

  public static DeviceInfo getUser(Context paramContext)
  {
    return aw.a(paramContext).b(paramContext);
  }

  public static String getUserID(Context paramContext)
  {
    monitorenter;
    while (true)
      try
      {
        if ((a != null) && (a.trim().length() != 0))
        {
          paramContext = a;
          return paramContext;
        }
        paramContext = Util.getDeviceID(paramContext);
        a = paramContext;
        if ((paramContext == null) || (a.trim().length() == 0))
          a = Integer.toString(b().nextInt(2147483647));
      }
      finally
      {
        monitorexit;
      }
  }

  public static int hasRootAccess(Context paramContext)
  {
    if (l != -1)
      return l;
    try
    {
      if (o.a())
        l = 1;
      l = 0;
      return 0;
    }
    catch (Throwable paramContext)
    {
      m.e(paramContext);
    }
  }

  public static boolean haveGravity(Context paramContext)
  {
    return ((SensorManager)paramContext.getSystemService("sensor") == null);
  }

  public static boolean isBackgroundRunning(Context paramContext)
  {
    ActivityManager.RunningAppProcessInfo localRunningAppProcessInfo;
    if (paramContext == null)
      return false;
    Object localObject = (ActivityManager)paramContext.getSystemService("activity");
    if (localObject == null)
      return false;
    paramContext = paramContext.getPackageName();
    localObject = ((ActivityManager)localObject).getRunningAppProcesses().iterator();
    do
    {
      if (!(((Iterator)localObject).hasNext()))
        break label81;
      localRunningAppProcessInfo = (ActivityManager.RunningAppProcessInfo)((Iterator)localObject).next();
    }
    while (!(localRunningAppProcessInfo.processName.startsWith(paramContext)));
    return (localRunningAppProcessInfo.importance != 400);
    label81: return false;
  }

  public static boolean isSpecifyReportedValid(StatSpecifyReportedInfo paramStatSpecifyReportedInfo)
  {
    if (paramStatSpecifyReportedInfo == null)
      return false;
    return isStringValid(paramStatSpecifyReportedInfo.getAppKey());
  }

  public static boolean isStringValid(String paramString)
  {
    return ((paramString == null) || (paramString.trim().length() == 0));
  }

  public static int isTheFirstTimeActivate(Context paramContext)
  {
    monitorenter;
    while (true)
    {
      int i1;
      try
      {
        if (w != -1)
        {
          i1 = w;
          return i1;
        }
        checkFirstTimeActivate(paramContext);
      }
      finally
      {
        monitorexit;
      }
    }
  }

  public static boolean isWiFiActive(Context paramContext)
  {
    int i1;
    try
    {
      if (Util.checkPermission(paramContext, "android.permission.ACCESS_WIFI_STATE"))
      {
        paramContext = (ConnectivityManager)paramContext.getApplicationContext().getSystemService("connectivity");
        if (paramContext == null)
          break label100;
        paramContext = paramContext.getAllNetworkInfo();
        if (paramContext == null)
          break label100;
        i1 = 0;
        if (i1 >= paramContext.length)
          break label100;
        if ((!(paramContext[i1].getTypeName().equalsIgnoreCase("WIFI"))) || (!(paramContext[i1].isConnected())))
          break label93;
        return true;
      }
      m.warn("can not get the permission of android.permission.ACCESS_WIFI_STATE");
      label93: return false;
    }
    catch (Throwable paramContext)
    {
      while (true)
        m.e(paramContext);
      i1 += 1;
    }
    label100: return false;
  }

  public static String md5sum(String paramString)
  {
    if (paramString == null)
      return "0";
    try
    {
      Object localObject = MessageDigest.getInstance("MD5");
      ((MessageDigest)localObject).update(paramString.getBytes());
      paramString = ((MessageDigest)localObject).digest();
      localObject = new StringBuffer();
      int i1 = 0;
      while (i1 < paramString.length)
      {
        int i2 = paramString[i1] & 0xFF;
        if (i2 < 16)
          ((StringBuffer)localObject).append("0");
        ((StringBuffer)localObject).append(Integer.toHexString(i2));
        i1 += 1;
      }
      paramString = ((StringBuffer)localObject).toString();
      return paramString;
    }
    catch (Throwable paramString)
    {
    }
    return ((String)"0");
  }

  public static boolean needCheckTime(Context paramContext)
  {
    if (x < 0L)
      x = StatPreferences.getLong(paramContext, "mta.qq.com.checktime", 0L);
    return (Math.abs(System.currentTimeMillis() - x) <= 86400000L);
  }

  public static int readDiffTimeFromServer(Context paramContext)
  {
    return StatPreferences.getInt(paramContext, "mta.qq.com.difftime", 0);
  }

  public static void updateCheckTime(Context paramContext)
  {
    x = System.currentTimeMillis();
    StatPreferences.putLong(paramContext, "mta.qq.com.checktime", x);
  }

  public static void writeDiffTimeFromServer(Context paramContext, int paramInt)
  {
    y = paramInt;
    StatPreferences.putInt(paramContext, "mta.qq.com.difftime", paramInt);
  }
}